typedef struct {
	unsigned char opcode;
	unsigned int target;
	unsigned char rs;
	unsigned char rt;
	unsigned char rd;
	unsigned char sh;
	unsigned char fn;

	signed short imm;

} instr;

void decode(unsigned int ic, instr* i);

enum {
	LB = 	0x20 ,//0b100000,
	LH = 	0x21 ,//0b100001,
	LW = 	0x23 ,//0b100011,
	LBU = 	0x24 ,//0b100100,
	LHU = 	0x25 ,//0b100101,
	SB = 	0x28 ,//0b101000,
	SH = 	0x29 ,//0b101001,
	SW = 	0x2B ,//0b101011,

	ADDI =	0x08 ,//0b001000,
	ADDIU =	0x09 ,//0b001001,
	SLTI = 	0x0A ,//0b001010,
	SLTIU =	0x0B ,//0b001011,
	ANDI = 	0x0C ,//0b001100,
	ORI =	0x0D ,//0b001101,
	XORI =	0x0E ,//0b001110,
	LUI =	0x0F ,//0b001111,

	J = 	0x02 ,//0b000010,
	JAL = 	0x03 ,//0b000011,
	JR = 	0x00 ,//0b000000,

	BEQ = 	0x04 ,//0b000100,
	BNE = 	0x05 ,//0b000101,
	BLEZ = 	0x06 ,//0b000110,
	BGTZ = 	0x07 ,//0b000111,
//	BEQL = 	0b010100,
//	BNEL = 	0b010101,
//	BLEZL = 	0b010110,
//	BGTZL = 	0b010111,

	BMORE = 0x01 ,//0b000001,
	//	BLTZ = 	0b000001,
//	BGEZ = 	0b000001,
//	BLTZL = 	0b000001,
//	BGEZL = 	0b000001,
//	BLTZAL = 	0b000001,
//	BGEZAL = 	0b000001,
//	BLTZALL = 	0b000001,
//	BGEZALL = 	0b000001,

};

enum {
	D_BLTZ = 0x00 ,//0b00000,
	D_BGEZ = 0x01 ,//0b00001,
};

enum {
	F_JR = 0x08 ,//0b001000,
	F_JALR = 0x09 ,//0b001001,
};

enum {
	F_SLL = 	0x00 ,//0b000000,
	F_SRL = 	0x02 ,//0b000010,
	F_SRA = 	0x03 ,//0b000011,
	F_SLLV = 	0x04 ,//0b000100,
	F_SRLV = 	0x06 ,//0b000110,
	F_SRAV = 	0x07 ,//0b000111,

	F_ADD = 	0x20 ,//0b100000,
	F_ADDU = 	0x21 ,//0b100001,
	F_SUB = 	0x22 ,//0b100010,
	F_SUBU = 	0x23 ,//0b100011,
	F_AND = 	0x24 ,//0b100100,
	F_OR = 		0x25 ,//0b100101,
	F_XOR = 	0x26 ,//0b100110,
	F_NOR = 	0x27 ,//0b100111,

	F_SLT = 	0x2A ,//0b101010,
	F_SLTU = 	0x2B ,//0b101011,
};
